package com.beisita.config;

import com.alibaba.druid.pool.DruidDataSource;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import javax.annotation.Resource;
import javax.sql.DataSource;

@Configuration
public class ClickHouseDruidConfig {
    @Resource
    private JdbcClickHouseConfig jdbcClickHouseConfig ;
    @Bean
    public DataSource dataSource() {
        DruidDataSource datasource = new DruidDataSource();
        datasource.setUrl(jdbcClickHouseConfig.getUrl());
        datasource.setDriverClassName(jdbcClickHouseConfig.getDriverClassName());
        datasource.setInitialSize(jdbcClickHouseConfig.getInitialSize());
        datasource.setMinIdle(jdbcClickHouseConfig.getMinIdle());
        datasource.setMaxActive(jdbcClickHouseConfig.getMaxActive());
        datasource.setMaxWait(jdbcClickHouseConfig.getMaxWait());
        return datasource;
    }
}
